from django.contrib import admin

# Register your models here.
# 将模型注册到admin后台
from .models import Users, BuildInfo, AITestCase, AITestDetail


@admin.register(Users)
class UsersAdmin(admin.ModelAdmin):
    list_display = ("id", "username", "password", "email")
    search_fields = ("username", "email")


@admin.register(BuildInfo)
class BuildInfoAdmin(admin.ModelAdmin):
    list_display = (
        "id",
        "build_name",
        "build_version",
        "build_time",
        "build_url",
        "build_status",
        "reserved_field0",
        "reserved_field1",
        "reserved_field2",
    )
    search_fields = ("build_name", "build_version", "build_url")
    list_filter = ("build_status",)
    list_per_page = 10
    ordering = ("-build_time",)


@admin.register(AITestCase)
class AITestCaseAdmin(admin.ModelAdmin):
    list_display = ("id", "test_summary", "test_requirements", "detail", "remark")
    search_fields = ("test_summary", "test_requirements")
    list_filter = ()
    list_per_page = 10
    ordering = ()
    filter_horizontal = ("build_info",)


@admin.register(AITestDetail)
class AITestDetailAdmin(admin.ModelAdmin):
    list_display = ("id", "index", "expected_result", "test_step", "detail")
    search_fields = ("test_step", "expected_result")
    list_filter = ("ai_test_case",)
    list_per_page = 10
